/**
 * <copyright>
 * </copyright>
 *

 */
package ms.unicorn.language.languagedef.impl;

import ms.unicorn.language.languagedef.Anchor;
import ms.unicorn.language.languagedef.DecoratorLocation;
import ms.unicorn.language.languagedef.DockType;
import ms.unicorn.language.languagedef.LanguagedefPackage;
import ms.unicorn.language.languagedef.Parameter;
import ms.unicorn.language.languagedef.ParameterType;
import ms.unicorn.language.languagedef.XRectangle;
import ms.unicorn.language.languagedef.XReferenceExpression;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.xtext.xbase.XExpression;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Parameter</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ParameterImpl#getParamId <em>Param Id</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ParameterImpl#getValue <em>Value</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ParameterImpl#getDockValue <em>Dock Value</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ParameterImpl#getBoundValue <em>Bound Value</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ParameterImpl#getAnchorValue <em>Anchor Value</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ParameterImpl#getLocationValue <em>Location Value</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.ParameterImpl#getItem <em>Item</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ParameterImpl extends MinimalEObjectImpl.Container implements Parameter
{
  /**
   * The default value of the '{@link #getParamId() <em>Param Id</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParamId()
   * @generated
   * @ordered
   */
  protected static final ParameterType PARAM_ID_EDEFAULT = ParameterType.VISIBLE;

  /**
   * The cached value of the '{@link #getParamId() <em>Param Id</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParamId()
   * @generated
   * @ordered
   */
  protected ParameterType paramId = PARAM_ID_EDEFAULT;

  /**
   * The cached value of the '{@link #getValue() <em>Value</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getValue()
   * @generated
   * @ordered
   */
  protected XExpression value;

  /**
   * The default value of the '{@link #getDockValue() <em>Dock Value</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDockValue()
   * @generated
   * @ordered
   */
  protected static final DockType DOCK_VALUE_EDEFAULT = DockType.TOP;

  /**
   * The cached value of the '{@link #getDockValue() <em>Dock Value</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDockValue()
   * @generated
   * @ordered
   */
  protected DockType dockValue = DOCK_VALUE_EDEFAULT;

  /**
   * The cached value of the '{@link #getBoundValue() <em>Bound Value</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBoundValue()
   * @generated
   * @ordered
   */
  protected XRectangle boundValue;

  /**
   * The cached value of the '{@link #getAnchorValue() <em>Anchor Value</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAnchorValue()
   * @generated
   * @ordered
   */
  protected Anchor anchorValue;

  /**
   * The default value of the '{@link #getLocationValue() <em>Location Value</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLocationValue()
   * @generated
   * @ordered
   */
  protected static final DecoratorLocation LOCATION_VALUE_EDEFAULT = DecoratorLocation.SOURCE;

  /**
   * The cached value of the '{@link #getLocationValue() <em>Location Value</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getLocationValue()
   * @generated
   * @ordered
   */
  protected DecoratorLocation locationValue = LOCATION_VALUE_EDEFAULT;

  /**
   * The cached value of the '{@link #getItem() <em>Item</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getItem()
   * @generated
   * @ordered
   */
  protected XReferenceExpression item;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ParameterImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return LanguagedefPackage.Literals.PARAMETER;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ParameterType getParamId()
  {
    return paramId;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setParamId(ParameterType newParamId)
  {
    ParameterType oldParamId = paramId;
    paramId = newParamId == null ? PARAM_ID_EDEFAULT : newParamId;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.PARAMETER__PARAM_ID, oldParamId, paramId));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public XExpression getValue()
  {
    return value;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetValue(XExpression newValue, NotificationChain msgs)
  {
    XExpression oldValue = value;
    value = newValue;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LanguagedefPackage.PARAMETER__VALUE, oldValue, newValue);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setValue(XExpression newValue)
  {
    if (newValue != value)
    {
      NotificationChain msgs = null;
      if (value != null)
        msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.PARAMETER__VALUE, null, msgs);
      if (newValue != null)
        msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.PARAMETER__VALUE, null, msgs);
      msgs = basicSetValue(newValue, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.PARAMETER__VALUE, newValue, newValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DockType getDockValue()
  {
    return dockValue;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDockValue(DockType newDockValue)
  {
    DockType oldDockValue = dockValue;
    dockValue = newDockValue == null ? DOCK_VALUE_EDEFAULT : newDockValue;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.PARAMETER__DOCK_VALUE, oldDockValue, dockValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public XRectangle getBoundValue()
  {
    return boundValue;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetBoundValue(XRectangle newBoundValue, NotificationChain msgs)
  {
    XRectangle oldBoundValue = boundValue;
    boundValue = newBoundValue;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LanguagedefPackage.PARAMETER__BOUND_VALUE, oldBoundValue, newBoundValue);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setBoundValue(XRectangle newBoundValue)
  {
    if (newBoundValue != boundValue)
    {
      NotificationChain msgs = null;
      if (boundValue != null)
        msgs = ((InternalEObject)boundValue).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.PARAMETER__BOUND_VALUE, null, msgs);
      if (newBoundValue != null)
        msgs = ((InternalEObject)newBoundValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.PARAMETER__BOUND_VALUE, null, msgs);
      msgs = basicSetBoundValue(newBoundValue, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.PARAMETER__BOUND_VALUE, newBoundValue, newBoundValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Anchor getAnchorValue()
  {
    return anchorValue;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetAnchorValue(Anchor newAnchorValue, NotificationChain msgs)
  {
    Anchor oldAnchorValue = anchorValue;
    anchorValue = newAnchorValue;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LanguagedefPackage.PARAMETER__ANCHOR_VALUE, oldAnchorValue, newAnchorValue);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAnchorValue(Anchor newAnchorValue)
  {
    if (newAnchorValue != anchorValue)
    {
      NotificationChain msgs = null;
      if (anchorValue != null)
        msgs = ((InternalEObject)anchorValue).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.PARAMETER__ANCHOR_VALUE, null, msgs);
      if (newAnchorValue != null)
        msgs = ((InternalEObject)newAnchorValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.PARAMETER__ANCHOR_VALUE, null, msgs);
      msgs = basicSetAnchorValue(newAnchorValue, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.PARAMETER__ANCHOR_VALUE, newAnchorValue, newAnchorValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DecoratorLocation getLocationValue()
  {
    return locationValue;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setLocationValue(DecoratorLocation newLocationValue)
  {
    DecoratorLocation oldLocationValue = locationValue;
    locationValue = newLocationValue == null ? LOCATION_VALUE_EDEFAULT : newLocationValue;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.PARAMETER__LOCATION_VALUE, oldLocationValue, locationValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public XReferenceExpression getItem()
  {
    return item;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetItem(XReferenceExpression newItem, NotificationChain msgs)
  {
    XReferenceExpression oldItem = item;
    item = newItem;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LanguagedefPackage.PARAMETER__ITEM, oldItem, newItem);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setItem(XReferenceExpression newItem)
  {
    if (newItem != item)
    {
      NotificationChain msgs = null;
      if (item != null)
        msgs = ((InternalEObject)item).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.PARAMETER__ITEM, null, msgs);
      if (newItem != null)
        msgs = ((InternalEObject)newItem).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LanguagedefPackage.PARAMETER__ITEM, null, msgs);
      msgs = basicSetItem(newItem, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.PARAMETER__ITEM, newItem, newItem));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case LanguagedefPackage.PARAMETER__VALUE:
        return basicSetValue(null, msgs);
      case LanguagedefPackage.PARAMETER__BOUND_VALUE:
        return basicSetBoundValue(null, msgs);
      case LanguagedefPackage.PARAMETER__ANCHOR_VALUE:
        return basicSetAnchorValue(null, msgs);
      case LanguagedefPackage.PARAMETER__ITEM:
        return basicSetItem(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case LanguagedefPackage.PARAMETER__PARAM_ID:
        return getParamId();
      case LanguagedefPackage.PARAMETER__VALUE:
        return getValue();
      case LanguagedefPackage.PARAMETER__DOCK_VALUE:
        return getDockValue();
      case LanguagedefPackage.PARAMETER__BOUND_VALUE:
        return getBoundValue();
      case LanguagedefPackage.PARAMETER__ANCHOR_VALUE:
        return getAnchorValue();
      case LanguagedefPackage.PARAMETER__LOCATION_VALUE:
        return getLocationValue();
      case LanguagedefPackage.PARAMETER__ITEM:
        return getItem();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case LanguagedefPackage.PARAMETER__PARAM_ID:
        setParamId((ParameterType)newValue);
        return;
      case LanguagedefPackage.PARAMETER__VALUE:
        setValue((XExpression)newValue);
        return;
      case LanguagedefPackage.PARAMETER__DOCK_VALUE:
        setDockValue((DockType)newValue);
        return;
      case LanguagedefPackage.PARAMETER__BOUND_VALUE:
        setBoundValue((XRectangle)newValue);
        return;
      case LanguagedefPackage.PARAMETER__ANCHOR_VALUE:
        setAnchorValue((Anchor)newValue);
        return;
      case LanguagedefPackage.PARAMETER__LOCATION_VALUE:
        setLocationValue((DecoratorLocation)newValue);
        return;
      case LanguagedefPackage.PARAMETER__ITEM:
        setItem((XReferenceExpression)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case LanguagedefPackage.PARAMETER__PARAM_ID:
        setParamId(PARAM_ID_EDEFAULT);
        return;
      case LanguagedefPackage.PARAMETER__VALUE:
        setValue((XExpression)null);
        return;
      case LanguagedefPackage.PARAMETER__DOCK_VALUE:
        setDockValue(DOCK_VALUE_EDEFAULT);
        return;
      case LanguagedefPackage.PARAMETER__BOUND_VALUE:
        setBoundValue((XRectangle)null);
        return;
      case LanguagedefPackage.PARAMETER__ANCHOR_VALUE:
        setAnchorValue((Anchor)null);
        return;
      case LanguagedefPackage.PARAMETER__LOCATION_VALUE:
        setLocationValue(LOCATION_VALUE_EDEFAULT);
        return;
      case LanguagedefPackage.PARAMETER__ITEM:
        setItem((XReferenceExpression)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case LanguagedefPackage.PARAMETER__PARAM_ID:
        return paramId != PARAM_ID_EDEFAULT;
      case LanguagedefPackage.PARAMETER__VALUE:
        return value != null;
      case LanguagedefPackage.PARAMETER__DOCK_VALUE:
        return dockValue != DOCK_VALUE_EDEFAULT;
      case LanguagedefPackage.PARAMETER__BOUND_VALUE:
        return boundValue != null;
      case LanguagedefPackage.PARAMETER__ANCHOR_VALUE:
        return anchorValue != null;
      case LanguagedefPackage.PARAMETER__LOCATION_VALUE:
        return locationValue != LOCATION_VALUE_EDEFAULT;
      case LanguagedefPackage.PARAMETER__ITEM:
        return item != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (paramId: ");
    result.append(paramId);
    result.append(", dockValue: ");
    result.append(dockValue);
    result.append(", locationValue: ");
    result.append(locationValue);
    result.append(')');
    return result.toString();
  }

} //ParameterImpl
